package com.sinaapp.mrblog.game.Assasin.model;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.sinaapp.mrblog.game.Assasin.stage.GameStage;
import com.sinaapp.mrblog.game.Assasin.util.AssasinConst;
import com.sinaapp.mrblog.game.Assasin.util.AssasinManager;

public class ACircle extends BaseActor{

	public final static int STATE_RED = 0; 
	public final static int STATE_WHITE = 1;
	public final static int STATE_ALIVE = 2;
	public final static int STATE_DEAD = 3 ;
	
	
	float radius;
	float dis;
	float endRadius;
	float startRadius;
	float liveTime;
	BaseActor actor;
	
	public ACircle(BaseActor actor ,float liveTime, float startRadius, float endRadius , int state,float alpha) {
		super(-1, -1, 0f, 0f);
		this.endRadius = endRadius;
		this.startRadius = startRadius;
		if(state == STATE_RED){
			region = AssasinManager.redCircle;
		}else if(state == STATE_WHITE){
			region = AssasinManager.whiteCircle;
		}
		this.actor = actor;
		dis = endRadius - startRadius;
		radius = startRadius;
		this.alpha = alpha;
		this.liveTime = liveTime;
	}

	@Override
	public void act(float delta) {
		if(Math.abs(endRadius - radius)>0.2){
			 radius += dis/liveTime*delta;
			 setWidth(radius);
			 setHeight(radius);
			 setX(actor.getCenterX()-radius/2);
			 setY(actor.getCenterY()-radius/2);
		}
		
		if(getState()!=STATE_DEAD&&getStateTime()>liveTime){
			setState(STATE_DEAD);
		}
		super.act(delta);
	}

	@Override
	public void refreshStatus() {
	}

	@Override
	public TextureRegion getReadyRegion() {
		return region;
	}

	
	
}
